package vn.co.thn.android.videohot.adapter;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import vn.co.thn.android.videohot.R;
import vn.co.thn.android.videohot.VHApp;
import vn.co.thn.android.videohot.common.VHCommonAdapter;
import vn.co.thn.android.videohot.data.VHCategoryItemData;

public class VHCategorySpinnerAdapter extends VHCommonAdapter<VHCategoryItemData>{

	public VHCategorySpinnerAdapter(Context context, List<VHCategoryItemData> objects) {
		
		super(context, R.layout.vh_category_item, objects);
		VHCategoryItemData obj=new VHCategoryItemData();
		obj.setName("Chọn danh mục ");
		obj.setName_us("Chosse Category");
		
		objects.add(0, obj);
		VHCategoryItemData obj1=new VHCategoryItemData();
		obj1.setName("Khác");
		obj1.setName_us("Other");
		objects.add(obj1);
		// TODO Auto-generated constructor stub
	}
	@Override
	public View getDropDownView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		return getCustomView(position, convertView, parent);
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		return getCustomView(position, convertView, parent);
	}
	public View getCustomView(int position, View convertView, ViewGroup parent){
		View view = convertView;
		ViewHolder viewHolder;
		if (view == null) {
			view = mInflater.inflate(R.layout.vh_category_item, parent,false);
			viewHolder = new ViewHolder();
			viewHolder.name = (TextView) view.findViewById(R.id.name);
		
			
			view.setTag(viewHolder);
		} else {
			viewHolder = (ViewHolder) view.getTag();
		}
		if (VHApp.getLanguage().equalsIgnoreCase("vi")) {
			viewHolder.name.setText(getItem(position).getName());
		} else {
			viewHolder.name.setText(getItem(position).getName_us());
		}

		return view;
	}
	private class ViewHolder {
		TextView name;
	}
}
